<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>音乐盒</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            position: relative;
            width: 200px; 
            padding: 10px;
            background-color: rgb(154, 195, 201);
            margin: 100px auto;
            border: #dddddd; 2px solid;
            border-radius: 5px;
        }
        .box-foot{
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="box-head">
            <h2>疯羊儿的音乐盒</h2>
            <hr>
        </div>
        <div class="content">
            <input type="checkbox">七里香<br>
            <input type="checkbox">稻香<br>
            <input type="checkbox">雨一直下<br>
            <input type="checkbox">窗外雨<br>
            <input type="checkbox">云雨海<br>
            <input type="checkbox">蒲公英的约定<br>
            <input type="checkbox">花海<br>
            <input type="checkbox">爱你没差<br>
            <input type="checkbox">手写的从前<br>
            <input type="checkbox">Faded<br>
        </div>
        <div class="box-foot">
            <hr>
            <button id="selectAll">全选</button>
            <button id="cancleAll">取消全选</button>
            <button id="reverseAll">反选</button>
        </div>
    </div>
    <script>
        function $(id_name){
            return typeof id_name === 'string' ? document.getElementById(id_name) : null;
        }
        var inputs = document.getElementsByTagName('input')
        $('selectAll').onclick = function(){
            for(var i=0;i<inputs.length;i++){
                inputs[i].checked = true;
            }
        }
        $('cancleAll').onclick = function(){
            for(var i=0;i<inputs.length;i++){
                inputs[i].checked = false;
            }
        }
        $('reverseAll').onclick = function(){
            for(var i=0;i<inputs.length;i++){
                inputs[i].checked = !inputs[i].checked;
                
            }
        }
    </script>
</body>
</html>